package com.test.blogsystem.Controller;


import com.test.blogsystem.Pojo.Response.BlogAddResponse;
import com.test.blogsystem.Pojo.Response.BlogInfoResponse;
import com.test.blogsystem.Service.BlogService;
import com.test.blogsystem.Service.Impl.BlogServiceImpl;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/blog")
public class BlogController {
    @Resource(name = "blogServiceImpl")
    private BlogService blogService;

    @RequestMapping("/getList")
    public List<BlogInfoResponse> getList() {
        return blogService.getList();
    }

    @RequestMapping("/getBlogDetail")
    public BlogInfoResponse getBlogDetail(@Nonnull Integer blogId){
        return blogService.getBlogDetail(blogId);
    }

    @RequestMapping("/add")
    public boolean add(@RequestBody @Validated BlogAddResponse blogAddResponse){
        return blogService.addBlog(blogAddResponse);
    }
}
